class EnvConfig {
  final String baseUrl;
  final String apiKey;
  final String appName;
  static final Map<String, dynamic> _envConfig = {
    "development": {
      "baseUrl": "https://leshi.test.sports-circle.com/inter",
      "apiKey": "123456",
      "appName": "Github",
    },
    "production": {
      "baseUrl": "https://api.github.com-prod",
      "apiKey": "123456",
      "appName": "Github",
    }
  };

  EnvConfig._({
    required this.baseUrl,
    required this.apiKey,
    required this.appName,
  });

  static EnvConfig? _instance;

  factory EnvConfig() {
    if (_instance == null) {
      throw Exception('EnvConfig未初始化');
    }
    return _instance!;
  }

  static void init() {
    const flutterEnv = String.fromEnvironment('FLUTTER_ENV');
    final config = _envConfig[flutterEnv];
    _instance = EnvConfig._(
      baseUrl: config['baseUrl'],
      apiKey: config['apiKey'],
      appName: config['appName'],
    );
  }
}

final envConfig = EnvConfig();
